package com.baosight.sczx.zm.service;

import com.baosight.iplat4j.core.ei.EiBlockMeta;
import com.baosight.iplat4j.core.ei.EiColumn;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.ep.ServiceEPBase;
import com.baosight.sczx.common.zm.basetools.StaticTools;

/**
 * 
 * <p>Title: ServiceZM9H.java</p>
 * <p>Description: 首页安全统计——查看更多</p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 郭淑芳
 * @version 1.0
 * <pre>Histroy:
 *          2012-12-24 上午03:12:06  郭淑芳  Create
 *</pre>
 */
public class ServiceZM9H extends ServiceEPBase {

	/**
	 * 
	 * <p>Function: initLoad</p>
	 * <p>Description: 初始化  </p>
	 * <p>return value: ServiceZM9G</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2012-12-13上午05:48:16 郭淑芳
	 * </p>
	 *
	 */
	@Override
	public EiInfo initLoad(EiInfo inInfo) 
	{
		inInfo.addBlock(EiConstant.resultBlock).set("showCount", "true");//如果不加这个，翻页的统计和显示是错误的
		EiInfo outInfo = this.query(inInfo);
		return outInfo;
	}
	
	/**
	 * 隐患统计
	 * <p>Function: query</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZM9G</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2012-12-13上午05:48:40 郭淑芳
	 * </p>
	 *
	 */
	public EiInfo query(EiInfo inInfo) {

		String fdCurrentDate = StaticTools.getDate(); // 当前日期
		String fdBeginDate = StaticTools.getFirDay(fdCurrentDate); // 当月开始日期

		StaticTools.setQueryParameters(inInfo, "fdBeginDate", fdBeginDate, true);// 截止日期
		StaticTools.setQueryParameters(inInfo, "fdCurrentDate", fdCurrentDate, true);// 截止日期

		// 隐患地点分布统计查询
		EiInfo outInfo = super.query(inInfo, "ZM9G.queryForIndexRisk", initMetaData());
		return outInfo;
	}
	
	/**
	 * 
	 * <p>Function: initMetaData</p>
	 * <p>Description: 初始化 EiBlockMeta（隐患地点分布统计查询结果block） </p>
	 * <p>return value:EiBlockMeta</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2012-12-13上午05:51:11 郭淑芳
	 * </p>
	 *
	 */
	public static EiBlockMeta initMetaData() {
		EiBlockMeta eiMetadata = new EiBlockMeta();
		EiColumn eiColumn;

		eiColumn = new EiColumn("fdDepartment");
		eiColumn.setType("C");
		eiColumn.setFieldLength(32);
		eiColumn.setDescName("部门");
		eiMetadata.addMeta(eiColumn);

		eiColumn = new EiColumn("fdRiskLevelA");
		eiColumn.setType("C");
		eiColumn.setDescName("A级");
		eiMetadata.addMeta(eiColumn);
		
		eiColumn = new EiColumn("fdRiskLevelB");
		eiColumn.setType("C");
		eiColumn.setDescName("B级");
		eiMetadata.addMeta(eiColumn);
		
		eiColumn = new EiColumn("fdRiskLevelC");
		eiColumn.setType("C");
		eiColumn.setDescName("C级");
		eiMetadata.addMeta(eiColumn);
		
		eiColumn = new EiColumn("fdRiskLevelSum");
		eiColumn.setType("C");
		eiColumn.setDescName("合计");
		eiMetadata.addMeta(eiColumn);
		
		return eiMetadata;
	}
}
